package com.zmj.sy.mom.srv.aps.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZonedDateTime;

@Configuration
@EnableSwagger2WebMvc
//@EnableKnife4j
public class SwaggerConfig {

    @Bean
    public Docket defaultApi2() {
        return new Docket(DocumentationType.SWAGGER_2)
                .directModelSubstitute(LocalDateTime.class, String.class)
                .directModelSubstitute(LocalDate.class, String.class)
                .directModelSubstitute(LocalTime.class, String.class)
                .directModelSubstitute(ZonedDateTime.class, String.class)

                .apiInfo(apiInfo())
                .groupName("aps排产")//分组名称
                .enable(true)//是否开启swagger
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.zmj.sy.mom.srv.aps.controller"))// 扫描路径
                .paths(PathSelectors.any())// 扫描所有
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("排产")
                // 版本号
                .version("1.0")
                .termsOfServiceUrl("https://makainb.com")
                // 描述
                .description("排产")
                // 作者
                .contact(new Contact("makai", "https://makainb.com", "makai325@gmail.com"))
                .license("The Apache License, Version 2.0")
                .licenseUrl("http://www.apache.org/license/LICENSE-2.0.html")
                .build();
    }

}
